<template>
  <div class="topuserbox">
    <el-row class="tac">
      <el-col :span="4">
        <h3 class="mb-2">个人中心</h3>
        <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
        >
          <el-menu-item index="1" @click="toIndex">
            <el-icon>
              <User/>
            </el-icon>
            <span>我的个人资料</span>
          </el-menu-item>
          <el-menu-item v-if="user !== null && user.urole !== 1" index="2" @click="toNews">
            <el-icon>
              <Tickets/>
            </el-icon>
            <span>我发布的新闻</span>
          </el-menu-item>
          <el-menu-item index="3" @click="toAssis">
            <el-icon>
              <Sunny/>
            </el-icon>
            <span>我的求助</span>
          </el-menu-item>
          <el-menu-item index="4" @click="toPet">
            <el-icon>
              <Lollipop/>
            </el-icon>
            <span>发布的宠物</span>
          </el-menu-item>
          <el-menu-item index="5" @click="toVolunte">
            <el-icon>
              <TrophyBase/>
            </el-icon>
            <span>我的志愿活动</span>
          </el-menu-item>
          <el-menu-item index="6" @click="toDonate">
            <el-icon>
              <Help/>
            </el-icon>
            <span>我的捐赠</span>
          </el-menu-item>
        </el-menu>
      </el-col>
      <el-col :span="20">
        <div class="userChild">
          <router-view @flush="flush"></router-view>
        </div>
      </el-col>
    </el-row>

  </div>
</template>

<script>
export default {
  name: "UserInfor",
  data() {
    return {
      user: {
        uid: '',
        uname: '',
        upassword: '',
        uphone: '',
        ugender: '',
        uimg: '',
        isreal: '',
        idnumber: '',
        urealname: '',
        urole: '',
        createdate: '',
      },
    }
  },
  methods: {
    flush(e) {
      this.$checkLogin()
      this.user = e
      this.$emit("flush", this.user)
    },
    /**
     * 前往用户信息页面
     */
    toIndex() {
      this.$checkLogin()
      this.$router.push("/front/userInfo/userIndex")
    },
    /**
     * 前往发布的新闻页面
     */
    toNews() {
      this.$checkLogin()
      this.$router.push("/front/userInfo/userNews")
    },
    /**
     * 前往我的求助页面
     */
    toAssis() {
      this.$checkLogin()
      this.$router.push("/front/userInfo/userAssis/UserAss")
    },
    /**
     * 前往宠物页面
     */
    toPet() {
      this.$checkLogin()
      this.$router.push("/front/userInfo/UserPet")
    },
    /**
     * 前往志愿活动页面
     */
    toVolunte() {
      this.$checkLogin()
      this.$router.push("/front/userInfo/UserVolunte/myjoin")
    },
    /**
     *
     */
    toDonate() {
      this.$checkLogin()
      this.$router.push("/front/userInfo/donate/donateMoney")
    },
  },
  mounted() {
    this.$checkLogin()
    this.user = JSON.parse(localStorage.getItem("user"))
    console.log(this.user)
  },
  onUpdated() {
    console.log("刷新")
  }
}
</script>

<style scoped>
.topuserbox {
  background: #ffff;
  width: 1200px;
  height: 720px;
  padding: 20px;
  margin: 0 auto;
}

.el-menu-vertical-demo {
  height: 715px;
}

.userChild {
  width: 100%;
  padding: 20px;
}
</style>